function js_alert(content, title, callback) {
  var title = title || '提示';
  $.alert(content, title, function () {
    if (typeof (callback) == "function") {
      callback();
    }
    
  })
}

function js_message(content, callback) {
  var content = content || '操作成功';
  $.toast(content, function () {
    if (typeof (callback) == "function") {
      callback();
    }
  })
}

function js_request(url, data, callback) {
  $.post(url, data, function (result) {
    if (!result) {
      js_alert('网络故障');
      return false;
    }
    if (result.code == -1) {
      window.location.href = '/mobile/login.html';
    }
    if (result.code == -2) {
      //js_alert(result.msg,'提醒');
      $.modal({
        title: "提醒",
        text: result.msg,
        buttons: [
          {
            text: "理解", onClick: function () {
              $.closeModal();
              window.location.href='login.html'
            }
          },
        ],
      });
      return false;
    }
    if (typeof (callback) == 'function') {
      callback(result);
    }
  })
}

function setCookie(c_name, value, expiredays) {
  var exdate = new Date()
  exdate.setDate(exdate.getDate() + expiredays)
  document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
}

//取回cookie
function getCookie(c_name) {
  if (document.cookie.length > 0) {
    c_start = document.cookie.indexOf(c_name + "=")
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1
      c_end = document.cookie.indexOf(";", c_start)
      if (c_end == -1) c_end = document.cookie.length
      return unescape(document.cookie.substring(c_start, c_end))
    }
  }
  return ""
}

var urlTools = {
  //获取RUL参数值
  getUrlParam: function (name) {               /*?videoId=identification  */
    var params = decodeURI(window.location.search);        /* 截取？号后面的部分    index.html?act=doctor,截取后的字符串就是?act=doctor  */
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = params.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
  }
};